<!DOCTYPE html>
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
<html><head>

<title>开票信息</title>

<meta name="description" content="">
<meta name="keywords" content="">
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
<meta charset="UTF-8">
<link rel="stylesheet" href="../../resource/weuimin.css"/>
<link rel="stylesheet" href="../../resource/example.css"/>
<script src="../../resource/jquery1.js"></script>
<script type="text/javascript" src="../../resource/wapcommon.js"></script>
<script type="text/javascript" src="../../resource/common.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<link rel="stylesheet" href="../../resource/jinsuistyle.css" />
<script type="text/javascript" src="../../script/constants.js"></script>

</head>
<body>
	<div style="background: #27a8fa" id="jsheader">
		<nav id="jsnav">
				<a id="jsleft" tapmode="" onclick="api.closeWin();">
						<span>返回</span>
				</a>
				<div id="jsmiddle">
						<strong id="jstitle">极速开票</strong>
				</div>
				<a id="jsright">
					<span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>
				</a>
		</nav>
</div>
	<div style="height:40px">&nbsp;</div>
	<div id="loadingToast" style="display:none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-loading weui-icon_toast"></i>
            <p class="weui-toast__content">数据加载中</p>
        </div>
	</div>
	<div id="waitToast" style="display:none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-loading weui-icon_toast"></i>
            <p class="weui-toast__content">请稍后...</p>
        </div>
	</div>
   <div class="weui-cells__title"><h1 class="page__title">开票信息</h1></div>
	<form id="ff">
	<input type="hidden" id="id" name="id" />
        <div class="weui-cells">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <input id="userName" name="userName" class="weui-input" type="text" placeholder="请输入您要开票的单位名称或个人"/>
                <input id="openId" name="openId" type="hidden" />

                </div>
            </div>
        </div>
        <div class="weui-cells">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <input id="taxCode" name="taxCode" class="weui-input" type="text" placeholder="请输入发票税号（增值税专用发票必填）"/>
                </div>
            </div>
        </div>
        <div class="weui-cells">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <input id="address"  name="address" class="weui-input" type="text" placeholder="请输入单位地址（增值税专用发票必填）"/>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <input id="phoneNumber" name="phoneNumber" class="weui-input" type="number" pattern="[0-9]*" placeholder="请输入单位电话（增值税专用发票必填）"/>
                </div>
            </div>
        </div>
        <div class="weui-cells">
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <input style="width:100%" id="bankName"  name="bankName" class="weui-input" type="text" placeholder="请输入开户银行（增值税专用发票必填）"/>
                </div>
            </div>
            <div class="weui-cell">
                <div class="weui-cell__bd">
                    <input id="bankNumber" name="bankNumber" class="weui-input" type="number" pattern="[0-9]*" placeholder="请输入银行帐号（增值税专用发票必填）"/>
                </div>
            </div>
        </div>
	<div id="errorInfo"   style="height:20px;text-align: center;color: red;">
	</div>
	<div class="page__bd page__bd_spacing">
        <a style="background: #27a8fa" href="javascript:;" id="saveBtn" onclick="saveInfo();" class="weui-btn weui-btn_primary">修改</a>
        <a style="background: #27a8fa" href="javascript:;" id="delBtn" onclick="deleteInfo()" class="weui-btn weui-btn_warn">删除</a>
	</div>

	<div class="js_dialog" id="iosDialog2" style="display: none;">
            <div class="weui-mask"></div>
            <div class="weui-dialog">
                <div class="weui-dialog__bd">保存失败，请重试！</div>
                <div class="weui-dialog__ft">
                    <a href="javascript:;" onclick="$('#iosDialog2').fadeOut(200);" class="weui-dialog__btn weui-dialog__btn_primary">确定</a>
                </div>
            </div>
        </div>
        <div id="toast" style="display: none;">
        <div class="weui-mask_transparent"></div>
        <div class="weui-toast">
            <i class="weui-icon-success-no-circle weui-icon_toast"></i>
            <p class="weui-toast__content">保存成功！</p>
        </div>
    </div>
</form>

<img src="resource/wapstat.htm" height="0" width="0">
<script type="text/javascript" src="resource/jweixin1002.js"></script>
<script type="text/javascript" src="resource/jweixin1.js"></script>

<script type="text/javascript">
	var openid = $api.getStorage('openid');;
	$("#openId").val(openid);

	function saveInfo(){
		$("#waitToast").fadeIn(100);
	$("#errorInfo").html("");
	if(!unionTools.isNullValue($("#userName").val())){
		$("#errorInfo").html("请输入您要开票的单位名称或个人");
		return;
	}


		api.ajax({
    		url: url.bjkpxx,
    		method: 'post',
    		data: {
    		    values: {
    		        id : $("#id").val(),
    		        userName : $("#userName").val(),
    		        openId : $("#openId").val(),
    		        taxCode : $("#taxCode").val(),
    		        address : $("#address").val(),
    		        phoneNumber : $("#phoneNumber").val(),
    		        bankName : $("#bankName").val(),
    		        bankNumber : $("#bankNumber").val()
    		    }
    		}
		}, function(ret, err) {
    		if (ret) {
   		     if(ret.success==true){
        		var $toast = $('#toast');
        		if ($toast.css('display') != 'none') return;
                $toast.fadeIn(100);
                setTimeout(function () {
                    $toast.fadeOut(100);
// 	        		window.location.href='<%=contextPath%>/wx/index.jsp';
	        		clearInput();
	        		api.sendEvent({
    					name: 'edit_reload',
   					 extra: {
       					 key1: '1'
    					}
					});
					api.closeWin();
                }, 500);
        	}else{
        		$('#iosDialog2').fadeIn(200);
        	}
  		  } else {
   		     $('#iosDialog2').fadeIn(200);
   		     api.alert({msg:'网络异常'});
   		 }
		});


	setTimeout(function () {
		$("#waitToast").fadeOut(100);
    },1000);
}

	var id;

			apiready = function(){
			$("#loadingToast").show();
				var header = $api.byId('jsheader');
				if(api.systemType=='ios'){
					$api.fixIos7Bar(header);
				}
//				else{
//					$api.fixStatusBar(header);
//				}
			id = api.pageParam.id;
			var flag = api.pageParam.flag;
			if(flag == 0){
			  $("#saveBtn").hide();
			  $("#delBtn").hide();
			}
			//api.alert({msg:id});
			api.ajax({
   			 url: url.kpxxxx,
   			 method: 'post',
   			 data: {
    			    values: {
     			       id: id
      			  }
   			 }
			}, function(ret, err) {
			$("#loadingToast").hide();
   			 if (ret) {
   			    $("#userName").val(ret[0].USERNAME);
	        	$("#taxCode").val(ret[0].TAXCODE);
	        	$("#address").val(ret[0].ADDRESS);
	        	$("#phoneNumber").val(ret[0].PHONE_NUMBER);
	        	$("#bankName").val(ret[0].BANK_NAME);
	        	$("#bankNumber").val(ret[0].BANK_NUMBER);
	        	$("#id").val(id);
   			 } else {
   			    //api.alert({ msg: JSON.stringify(err) });
   			    api.alert({msg:'网络异常'});
   			 }
			});
		}
		

	function deleteInfo(){
		$("#waitToast").fadeIn(100);
		api.ajax({
   			 url: url.sckpxx,
   			 method: 'post',
   			 data: {
    			    values: {
     			       id: id
     			   }
   			 }
			}, function(ret, err) {
   			 if (ret) {
    			    if(ret.success==true){
// 	        		window.location.href='<%=contextPath%>/wx/index.jsp';
	        		clearInput();
	        		api.sendEvent({
    					name: 'del_reload',
   					 extra: {
       					 key1: '1'
    					}
					});
					api.closeWin();
	        	}
   			 } else {
   			     //api.alert({ msg: JSON.stringify(err) });
   			     api.alert({msg:'网络异常'});
   			 }
			});
		setTimeout(function () {
			$("#waitToast").fadeOut(100);
        },2000);
	}

	function clearInput(){
		$("#userName").val("");
		$("#taxCode").val("");
		$("#address").val("");
		$("#phoneNumber").val("");
		$("#bankName").val("");
		$("#bankNumber").val("");
	}
</script>
<div class="page__ft">
<!--<a style="color:#777;font-size:12px">四川航天金穗高技术有限公司</a>-->
</div>
</body></html>
